#include "hw1_wrappers.h"

int fork_n(int n)
{
	long __res;
	__asm__ volatile ( 
        "movl $243, %%eax;" 
        "movl %1, %%ebx;" 
        "int $0x80;" 
        "movl %%eax,%0" 
        : "=m" (__res)  
        : "m" (n) 
        : "%eax","%ebx"
    );
		
    if ((unsigned long)(__res) >= (unsigned long)(-125)) { 
        errno = -(__res); 
        __res = -1;
    }
	
    return (int)(__res);
} 

int checkpath(int *array, int size)
{
    long __res;
    __asm__ volatile (
        "movl $244, %%eax;"
        "movl %1, %%ebx;"
        "movl %2, %%ecx;"
        "int $0x80;"
        "movl %%eax,%0"
        : "=m" (__res) 
        : "m" ((long)array), "m" (size)
        : "%eax","%ebx","%ecx"
    );
    
    if ((unsigned long)(__res) >= (unsigned long)(-125)) {
        errno = -(__res);
        __res = -1;
    }
    
    return (int)(__res);
}
